from rest_framework.generics import ListAPIView
from rest_framework.viewsets import ModelViewSet
from  rest_framework.permissions import IsAdminUser

from goods.models import SpecificationOption, SPUSpecification
from meiduo_admin.serializers.options import OptionSerializer
from meiduo_admin.serializers.options import OptionSimpleSerializer


class OptionViewSet(ModelViewSet):
    """规格选项序列化器"""
    permission_classes = [IsAdminUser]

    serializer_class = OptionSerializer

    queryset = SpecificationOption.objects.all()


class OptionSimpleView(ListAPIView):
    # 规格选项简单展示视图
    permission_classes = [IsAdminUser]

    queryset = SPUSpecification.objects.all()

    serializer_class = OptionSimpleSerializer

    pagination_class = None
